#ifndef QANIMATESWIDGET_H
#define QANIMATESWIDGET_H

#include <QStackedWidget>
#include <QPropertyAnimation>
#include <QPaintEvent>
#include <QPainter>
#include <QPixmap>

//枚举值，Widget切换的方向
typedef enum {
    UptoDown,
    DowntoUp
}Direction;

class QAnimateSWidget : public QStackedWidget
{
    Q_OBJECT
public:
        explicit QAnimateSWidget(QWidget *parent = 0);
        void paintEvent(QPaintEvent *);
        //设置动画持续的间隔
        void setDuration(int );
        ~QAnimateSWidget();

signals:

public slots:
        //属性动画值改变的槽
        void valueChanged_slot(QVariant );
        //动画切换完成
        void animationFinished();
        //下一页
        void next();
        //上一页
        void forward();

private:
    void paintPrevious(QPainter &, int currentIndex);

    void paintNext(QPainter &, int);

private:
    QPropertyAnimation *animation;
    QVariant currentValue;
    bool isAnimation;
    int nextIndex;
    int duration;
    Direction direction;
};

#endif // QANIMATESWIDGET_H
